package plugin

import (
	"github.com/go-chi/chi/v5"
)

type Http func(r chi.Router)

var (
	HttpPublic  = make(map[string][]Http, 0)
	HttpPrivate = make(map[string][]Http, 0)
)

func RegHttpPublic(path string, p Http) {
	regHttp(path, p, true)
}

func RegHttpPrivate(path string, p Http) {
	regHttp(path, p, false)
}

func regHttp(path string, p Http, public bool) {
	var v map[string][]Http
	if public {
		v = HttpPublic
	} else {
		v = HttpPrivate
	}
	r := v[path]
	if r == nil {
		r = make([]Http, 0)
	}
	r = append(r, p)
	v[path] = r
}
